﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

using AwesomeEnginePC.Physics;
using AwesomeEnginePC.Graphics.TwoDimensional.Sprites;
using AwesomeEnginePC.Graphics.TwoDimensional.Text;

namespace AwesomeEnginePC.Graphics.TwoDimensional.Menus
{
    public class MenuLabel
    {
        private ContentManager _cm;
        private BaseSprite _backgroundSprite;
        protected BaseString _displayText;

		public string _Name;

		public virtual void Init()
		{
			_backgroundSprite.Active = true;
			
			if (_displayText != null)
				_displayText.Active = true;
		}

		public void ChangeDisplayText(string text)
		{
			_displayText.Text = text;
		}

		public void Init(string Name)
		{
			_Name = Name;
			Init();
		}

        public virtual Vector<int> Position
        {
            get
            {
                return _backgroundSprite.Position;
            }
            set
            {
                _backgroundSprite.Position = value;
				if(_displayText != null)
					_displayText.Position = value;
            }
        }

        public virtual int Height
        {
            get
            {
                return _backgroundSprite.Height;
            }
            set
            {
                _backgroundSprite.Height = value;
				if (_displayText != null)
					_displayText.Height = value;
            }
        }

        public virtual int Width
        {
            get
            {
                return _backgroundSprite.Width;
            }
            set
            {
                _backgroundSprite.Width = value;
				if (_displayText != null)
					_displayText.Width = value;
            }
        }

        /// <summary>
        /// Just the Content Manager
        /// </summary>
        /// <param name="cm"></param>
        public MenuLabel(ContentManager cm)
        {
            _cm = cm;
        }

        /// <summary>
        /// Just the Content Manager and some Text
        /// </summary>
        /// <param name="cm"></param>
        /// <param name="spriteFontAssetName"></param>
        /// <param name="text"></param>
        public MenuLabel(ContentManager cm, string spriteFontAssetName, string text)
        {
            _cm = cm;
            _displayText = new BaseString(cm, spriteFontAssetName, text);
        }

        /// <summary>
        /// Just the Content Manager and a Base String
        /// </summary>
        /// <param name="cm"></param>
        /// <param name="displayText"></param>
        public MenuLabel(ContentManager cm, BaseString displayText)
        {
            _cm = cm;
            _displayText = displayText;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="cm"></param>
        /// <param name="backgroundAssetName"></param>
        public MenuLabel(ContentManager cm, string backgroundAssetName)
        {
            _cm = cm;
            _backgroundSprite = new BaseSprite(cm, backgroundAssetName);
        }

        public MenuLabel(ContentManager cm, BaseSprite backgroundSprite)
        {
            _cm = cm;
            _backgroundSprite = backgroundSprite;
        }

        public MenuLabel(ContentManager cm, string backgroundAssetName, string spriteFontAssetName, string text)
        {
            _cm = cm;
            _backgroundSprite = new BaseSprite(cm, backgroundAssetName);
            _displayText = new BaseString(cm, spriteFontAssetName, text);
        }

        public MenuLabel(ContentManager cm, string backgroundAssetName, BaseString displayText)
        {
            _cm = cm;
            _backgroundSprite = new BaseSprite(cm, backgroundAssetName);
            _displayText = displayText;
        }

        public MenuLabel(ContentManager cm, BaseSprite backgroundSprite, BaseString displayTest)
        {
            _cm = cm;
            _backgroundSprite = backgroundSprite;
            _displayText = displayTest;
        }


        public virtual void Draw(GameTime gameTime, SpriteBatch SB)
        {
            //Background, then text
            _backgroundSprite.Draw(gameTime, SB);

			if (_displayText != null)
				_displayText.Draw(gameTime, SB);
        }
    }
}
